package com.lwj.liwanjia.presenter;

import com.lwj.liwanjia.bean.DeleteAddressBean;
import com.lwj.liwanjia.impl.DeleteAddressView;
import com.lwj.liwanjia.model.DeleteAddressModel;

import rx.Subscriber;

/**
 * Created by Administrator on 2017/10/10.
 */

public class DeleteAddressPresenter {
    private DeleteAddressView deleteAddressView;
    private DeleteAddressModel deleteAddressModel;

    public DeleteAddressPresenter(DeleteAddressView deleteAddressView) {
        this.deleteAddressView = deleteAddressView;
        deleteAddressModel = new DeleteAddressModel();
    }

    public void deleteAddress(String token, String consigneeId) {
        if (deleteAddressView != null) {
            deleteAddressModel.deleteAddress(token, consigneeId, new Subscriber<DeleteAddressBean>() {
                @Override
                public void onCompleted() {

                }

                @Override
                public void onError(Throwable e) {
                    deleteAddressView.showError((Exception) e);
                }

                @Override
                public void onNext(DeleteAddressBean deleteAddressBean) {
                    deleteAddressView.deleteAddress(deleteAddressBean);
                }
            });
        }
    }
}
